#ifndef ATDEVICE_H
#define ATDEVICE_H

#include "TableWidgetForm.h"

struct AtDeviceConnectStr
{
    QString name;
    QString type;

    // 获取结构体成员名的字符串
    QString toFieldNames() const {
        return QString("name,type");
    }

    // 获取结构体成员名的字符串
    QStringList toFieldTypes() const {
        QStringList _list;
        _list << typeid(name).name();
        _list << typeid(type).name();
        return _list;
    }
};

struct AirBlower
{
    int id;
    QString name;
    int rotate;
    int board_id;
    int port;

    // 获取结构体成员名的字符串
    QString toFieldNames() const {
        return QString("name,rotate,board_id,port");
    }

    // 获取结构体成员名的字符串
    QStringList toFieldTypes() const {
        QStringList _list;
        _list << typeid(name).name();
        _list << typeid(rotate).name();
        _list << typeid(board_id).name();
        _list << typeid(port).name();
        return _list;
    }
};

struct WaterValue
{
    int id;
    QString name;
    int angle;
    int board_id;
    int port;

    // 获取结构体成员名的字符串
    QString toFieldNames() const {
        return QString("name,angle,board_id,port");
    }

    // 获取结构体成员名的字符串
    QStringList toFieldTypes() const {
        QStringList _list;
        _list << typeid(name).name();
        _list << typeid(angle).name();
        _list << typeid(board_id).name();
        _list << typeid(port).name();
        return _list;
    }
};

struct WindPress
{
    int id;
    QString name;
    int test;

    // 获取结构体成员名的字符串
    QString toFieldNames() const {
        return QString("name,test");
    }

    // 获取结构体成员名的字符串
    QStringList toFieldTypes() const {
        QStringList _list;
        _list << typeid(name).name();
        _list << typeid(test).name();
        return _list;
    }
};


class AtDevice
{
public:
    AtDevice();

    //初始化UI
    static void InitUI(const QString& fileName, QList<QPair<QWidget *, QString>>& widgets, QMap<int, QList<TableWidgetForm*>>& m_pTableWidgetFormMap);

    //保存
    static bool SaveUI(const QString& fileName, const QMap<int, QList<TableWidgetForm*>>& m_pTableWidgetFormMap);

    //解析
    static void Analysis(const QString& path, AtDeviceConnectStr& _AtDeviceConnectStr, QList<AirBlower>& _AirBlowerList, QList<WaterValue>& _WaterValueList,
                         WindPress& _WindPress);

    //保存
    static bool SaveXml(const QString& path, const AtDeviceConnectStr& _AtDeviceConnectStr, const QList<AirBlower>& _AirBlowerList, const QList<WaterValue>& _WaterValueList,
                        const WindPress& _WindPress);
};

#endif // ATDEVICE_H
